<!--
 * @Description:: 请补充填写
 * @Version: 1.0
 * @Author: smallWhite
 * @Date: 2023-05-12 20:36:16
 * @LastEditors: smallWhite
 * @LastEditTime: 2023-06-08 17:29:26
 * @FilePath: /siana_admin/src/views/system/baidu/index.vue
-->
<template>
  <el-card>
    <div slot="header">
      <h2>key消耗配置
      </h2>
    </div>
    <el-form ref="ruleForm"
             :model="form"
             :rules="rules"
             label-width="180px"
             :label-position="phone?'top':'right'"
             class="demo-ruleForm">
      <el-form-item
        label="gpt3.5"
        prop="gptNumber">
        <el-input
          v-model="form.gptNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="got4.0"
        prop="gpt4Number">
        <el-input
          v-model="form.gpt4Number"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="gpt绘图"
        prop="gptOfficialNumber">
        <el-input
          v-model="form.gptOfficialNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj画图"
        prop="mjNumber">
        <el-input
          v-model="form.mjNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj混合生图消耗"
        prop="mjBlendNumber">
        <el-input
          v-model="form.mjBlendNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj变换消耗"
        prop="mjVNumber">
        <el-input
          v-model="form.mjVNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj放大"
        prop="mjUNumber">
        <el-input
          v-model="form.mjUNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj文生图极速模式"
        prop="mjNumberFast">
        <el-input
          v-model="form.mjNumberFast"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj文生图涡轮模式"
        prop="mjNumberTurbo">
        <el-input
          v-model="form.mjNumberTurbo"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj文生图消耗"
        prop="mjDecNumber">
        <el-input
          v-model="form.mjDecNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="mj混合生图消耗"
        prop="mjBlendNumber">
        <el-input
          v-model="form.mjBlendNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        label="sd画图"
        prop="sdNumber">
        <el-input
          v-model="form.sdNumber"
          :disabled="disabled"
          style="width:100%;max-width: 600px;" />
      </el-form-item>
      <el-form-item
        v-if="!disabled">
        <el-button
          type="primary"
          @click="handleSubmit()">保存</el-button>
        <el-button
          @click="handleCancel()">取消</el-button>
      </el-form-item>
      <el-form-item v-else>
        <el-button
          type="primary"
          @click="disabled = !disabled">去编辑</el-button>

      </el-form-item>
    </el-form>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      phone: false,
      form: {
        gptNumber: '', // gpt3.5 配置项
        gpt4Number: '', // got4.0 配置项
        gptOfficialNumber: '', // gpt绘图 配置项
        mjNumber: '', // mj画图 配置项
        mjBlendNumber: '', // mj混合生图消耗 配置项
        mjVNumber: '', // mj变换消耗 配置项
        mjUNumber: '', // mj放大 配置项
        mjNumberFast: '', // mj文生图极速模式 配置项
        mjNumberTurbo: '', // mj文生图涡轮模式 配置项
        mjDecNumber: '', // mj文生图消耗 配置项
        sdNumber: '' // sd画图 配置项
      },
      disabled: true,
      rules: {
        gptNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        gpt4Number: [{ required: false, message: '请输入', trigger: 'blur' }],
        gptOfficialNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjBlendNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjVNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjUNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjNumberFast: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjNumberTurbo: [{ required: false, message: '请输入', trigger: 'blur' }],
        mjDecNumber: [{ required: false, message: '请输入', trigger: 'blur' }],
        sdNumber: [{ required: false, message: '请输入', trigger: 'blur' }]
      }
    }
  },
  mounted() {
    this.phone = JSON.parse(window.localStorage.getItem('phone'))
    this.getData()
  },
  methods: {
    getData() {
      this.$https('QUERYKEYCONFIG', {}).then(res => {
        this.form = {
          id: res.data.id,
          gptNumber: res.data.gptNumber, // gpt3.5 配置项
          gpt4Number: res.data.gpt4Number, // got4.0 配置项
          gptOfficialNumber: res.data.gptOfficialNumber, // gpt绘图 配置项
          mjNumber: res.data.mjNumber, // mj画图 配置项
          mjBlendNumber: res.data.mjBlendNumber, // mj混合生图消耗 配置项
          mjVNumber: res.data.mjVNumber, // mj变换消耗 配置项
          mjUNumber: res.data.mjUNumber, // mj放大 配置项
          mjNumberFast: res.data.mjNumberFast, // mj文生图极速模式 配置项
          mjNumberTurbo: res.data.mjNumberTurbo, // mj文生图涡轮模式 配置项
          mjDecNumber: res.data.mjDecNumber, // mj文生图消耗 配置项
          sdNumber: res.data.sdNumber, // sd画图 配置项
        }
      })
    },
    handleSubmit() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.$https('UPDATEKEYCONFIG', this.form).then(res => {
            if (res.status === 200) {
              this.$message.success('编辑成功！')
              this.disabled = true
            }
          })
        }
      })
    },
    handleCancel() {
      this.form = {
        id: '',
        gptNumber: '',
        gpt4Number: '',
        gptOfficialNumber: '',
        mjNumber: '',
        mjBlendNumber: '',
        mjVNumber: '',
        mjUNumber: '',
        mjNumberFast: '',
        mjNumberTurbo: '',
        mjDecNumber: '',
        sdNumber: ''
      }
      this.getData()
      this.disabled = true
    }
  }
}
</script>

<style>
</style>
